<?php
header("Content-Type:text/html; charset=uft-8"); 
ob_start();
require("inc/common.inc.php");
ob_end_clean();
//判断是否匹配
if (trim($appactions)=="getuserid"){
	$thissign=md5(appkeys."mx".$appactions."mx".$mobile);
	if (strtolower(trim($mysign))!=$thissign){
		exit();
	}
	$mobile=substr($mobile,3,strlen($mobile)-3);
	if(!eregi("^[0-9]{11,11}$",$mobile) and trim($mobile)!=""){
		exit();
	}
	$db->excu("insert into mx_app_user (mobile,regdate,isok,logindays,logintimes,lastlogintime) values ('$mobile','".date("Y-m-d H:i:s")."','1','1','1','".date("Y-m-d H:i:s")."')");
	$userid = mysql_insert_id();
	echo $userid;
	exit();
}
elseif (trim($appactions)=="setuseraddress"){
	$id=intval($id);
	$thissign=md5(appkeys."mx".$appactions."mx".$id."mx".$latitude."mx".$longitude);
	if (strtolower(trim($mysign))!=$thissign){
		exit();
	}
	//判断用户是否存在
	$userinfo=$db->getinfo("select * from mx_app_user where id='$id' limit 1");
	if (!is_array($userinfo)){exit();}
	
	$aa=get_maps_addinfo($latitude,$longitude);
	$province=$aa[province];
	$city=$aa[city];
	$district=$aa[district];
	$address=$aa[address];
	
	if(date("Y-m-d",strtotime($userinfo["lastlogintime"]))!=date("Y-m-d")){
		//判断是否当天第一次登陆
		$db->excu("update mx_app_user set weizhix='$latitude',weizhiy='$longitude',province='$province',city='$city',district='$district',address='$address',mapupdate='".date("Y-m-d H:i:s")."',logindays=logindays+1,logintimes=logintimes+1,lastlogintime='".date("Y-m-d H:i:s")."' where id='$id'");
	}
	else{
		//只更新最后坐标
		$db->excu("update mx_app_user set weizhix='$latitude',weizhiy='$longitude',province='$province',city='$city',district='$district',address='$address',mapupdate='".date("Y-m-d H:i:s")."' where id='$id'");
	}
	$db->excu("insert into mx_app_user_wzlog (userid,weizhix,weizhiy,province,city,district,adddate) values ('$id','$latitude','$longitude','$province','$city','$district','".date("Y-m-d H:i:s")."')");
	exit();
}
?>